package com.example.hospitalManage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.hospitalManage.dao.*;
import com.example.hospitalManage.entity.Department;
import com.example.hospitalManage.entity.OrderOrderInfo;
import com.example.hospitalManage.entity.Schedule;
import com.example.hospitalManage.service.ScheduleService;
import com.example.hospitalManage.service.UserAppointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @projectName: hospitalManage
 * @package: com.example.hospitalManage.service.impl
 * @className: UserAppointServiceImpl
 * @author: GCT
 * @description: TODO
 * @date: 2022/12/31 12:27
 * @version: 1.0
 */
@Service
public class UserAppointServiceImpl extends ServiceImpl<OrderOrderInfoMapper, OrderOrderInfo> implements UserAppointService {
    @Autowired
    DepartmentMapper departmentMapper;
    @Autowired
    HospitalMapper hospitalMapper;
    @Autowired
    ScheduleMapper scheduleMapper;
    @Autowired
    PatientMapper patientMapper;

//    @Transactional
    @Override
    public List<Department> getDepartmentByHosname(String hosname) {
        String hoscodeByHosname = hospitalMapper.getHoscodeByHosname(hosname);
        List<Department> departmentByHoscode = departmentMapper.getDepartmentByHoscode(hoscodeByHosname);

        return departmentByHoscode;
    }

//    @Transactional
    @Override
    public List<Schedule> getScheduleByDepname(String depname) {
        String depcodeByDepname = departmentMapper.getDepcodeByDepname(depname);
        List<Schedule> scheduleByDepcode = scheduleMapper.getScheduleByDepcode(depcodeByDepname);

        return scheduleByDepcode;
    }

//    @Transactional
    @Override
    public String getHoscodeByHosname(String hosname) {
        String hoscodeByHosname = hospitalMapper.getHoscodeByHosname(hosname);
        return hoscodeByHosname;
    }

//    @Transactional
    @Override
    public String getDepcodeByDepname(String depname) {
        String depcodeByDepname = departmentMapper.getDepcodeByDepname(depname);
        return depcodeByDepname;
    }

//    @Transactional
    @Override
    public Long getPatientIdByPatientName(String name) {
        Long idByName = patientMapper.getIdByName(name);
        return idByName;
    }
}
